<!-- 添加备注(赠品) -->
<div class="float-confirm float-confirm-dialog js_addCommentsDiv" style="display: none; width:auto;">
    <div class="float-confirm-con">
        <h2 class="fs22 blue2 line">添加备注(赠品)</h2>
        <div class="line" style="height:auto;">
            <table>
                <tr>
                    <td>内容</td>
                </tr>
                <tr>
                    <td>
                        <textarea style="min-width:400px;" name="comments"
                                  class="add-f-area textarea_box js_input_comments"></textarea>
                    </td>
                </tr>
            </table>
        </div>
        <div class="float-confirm-btns" style="padding-bottom:30px;">
            <a class="btn btn-default btn-sm right js_cancel" href="javascript:void(0);">取消</a>
            <a class="btn btn-success btn-sm right js_confirm" href="javascript:void(0);">确定</a>
        </div>
    </div>
</div>
<script>
    (function ($) {

        var el = $('.js_addCommentsDiv');

        var addComments = function (order_id) {
            showConfirmDiv(el, order_id);
            $.pageMask.show();
            getRTData();
        };

        function getRTData() {
            var order_id = el.data('id');
            $.post(
                    "{AnUrl('order/admin/ajax_get_real_time_order_data')}",
                    {
                        order_id: order_id
                    },
                    function (ret) {
                        if (ret && ret.flag === 0 && ret.response) {
                            var order_info = ret.response;
                            el.find('.js_input_comments').val(order_info.note);
                            return;
                        }
                        showMsg(ret.message || "接口请求失败, 请稍后重试");
                        el.hide();
                        $.pageMask.hide();
                    }
            )
        }

        //取消订单事件
        $('.js_addCommentsBtn').click(function () {
            var order_id = $(this).closest('tr').data('id');
            addComments(order_id);
        });

        //同意取消订单操作
        el.find('.js_confirm').click(function () {
            var note = $.trim(el.find('.js_input_comments').val());
            var order_id = el.data('id');

            if (!note || note == '') {
                showMsg('请填写备注信息');
                return false;
            }

            $.post(
                    "{AnUrl('order/admin/operation/dealer_action_add_goods')}",
                    {
                        note: note,
                        order_id: order_id
                    },
                    function (ret) {
                        if (ret && ret.flag === 0) {
                            showMsg(ret.message);
                            setTimeout(function () {
                                window.location.reload();
                            }, 1500);
                            return;
                        }
                        showMsg(ret.message || "接口请求失败, 请稍后重试");
                        el.hide();
                        $.pageMask.hide();
                    }
            );
        });

        window.order_operation.DEALER_ACTION_ADD_GOODS = addComments;
        console.log('order_operation.DEALER_ACTION_ADD_GOODS added! 添加备注(赠品)');
    })(jQuery);
</script>
<!-- /添加备注(赠品) -->